home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / rtnews.zip / RTNEWS1 < prev    next >
Text File  |  1992-09-13  |  76KB  |  1,470 lines

  1. "The Ray Tracing News" email edition began after some ray tracing researchers
  2. met at SIGGRAPH 87 and an address list was formed.  Andrew Glassner started
  3. "The Ray Tracing News", hardcopy edition, and soon thereafter we distributed
  4. copies of the email address list to researchers.
  5.  
  6. This is the first archive collection of "The Ray Tracing News".  I hope you
  7. will get as much use out of it as I have,
  8.  
  9.     Eric Haines, 3D/Eye Inc, 2359 N. Triphammer Rd, Ithaca, NY  14850
  10.     ...!hpfcla!hpfcrs!eye!erich
  11.  
  12. ----------------------------------------------------
  13.  
  14.     I'm presently keeping the list up-to-date.  As far as adding new people
  15. to this mailing list, I'd personally like to see the list not grow without
  16. bounds.  Given that the Intro to Ray Tracing course had the highest attendance,
  17. there's obviously a lot of people interested in ray-tracing.  The group
  18. presently consists of researchers and people building ray-tracing systems, and
  19. it'd be nice to keep it at this level (and keep all of our long-distance e-mail
  20. costs down).
  21.  
  22.     First off, a quick announcement:  if you didn't get a copy of the
  23. "Intro. to Ray Tracing" course notes at SIGGRAPH 87 and would like a copy
  24. (they sold out twice), send me $20 and I'll xerox them.  There are only three
  25. articles which are reprints - the rest is new stuff and pretty worthwhile.
  26.  
  27.  
  28. [Skip the next offering if you read it in The Ray Tracing News]
  29.  
  30. SPD & NETLIB:
  31.  
  32.     My news for the day is that netlib is now carrying my "standard"
  33. procedural database generators (written in C).  If you don't know about netlib,
  34. here's the two minute explanation:
  35.  
  36. -------------------------------------------------------------------------------
  37.  
  38.     Netlib has two addresses.  One is:
  39.  
  40.     ...!hplabs!hpfcla!research!netlib
  41.  
  42. (There may be other quicker routes to netlib - you'll have to research that
  43. yourself).  The second one may be more convenient, as it is an arpa connection:
  44.  
  45.     netlib@anl-mcs.arpa
  46.  
  47. So after you do "mail [...!]hplabs!hpfcla!research!netlib", the next step is to
  48. request what you want, one line per request.  For example, to get my databases,
  49. simply type on a single line (and don't have anything else on the line):
  50.  
  51.     send haines from graphics
  52.  
  53. and end the message.  Netlib is computerized, and will automatically parse
  54. your message and send you the 82K bytes of dox & code for my databases.
  55.  
  56.     The best way to find out about netlib and what it has to offer is to
  57. send it a request:
  58.  
  59.     send index
  60.  
  61. and you'll get sent a listing of all the libraries available.  It's mostly
  62. numerical analysissy stuff (lots'o'matrix solvers), but there are some things
  63. of interest.  One particularly yummy database is the "polyhedron"
  64. contributions.  There are some 142 polyhedra descriptions (vertices, faces, &
  65. edge descriptions and more).  Some of these descriptions are buggy, but most
  66. are good (as netlib says, "Anything free comes with no guarantee").
  67.  
  68. -----------------------------------------------------------------------------
  69.  
  70.     As far as the question "what do the images look like?" goes, the
  71. images will be published in IEEE CG&A in November.
  72.  
  73.  
  74. SPLINE SURFACES:
  75.  
  76.     A question which I want to answer is "which is the best way in
  77. software to ray-trace bicubic spline patches?"  In particular, I want to
  78. intersect bicubics (also quadrics and linears, and any mix of the three, e.g.
  79. bicubic u, quadric v) that can also be rational, and also have non-uniform
  80. knots.  As an added bonus, I'd like to do trimming curves.  I am interested in
  81. anyone's feelings or findings on this subject, especially any experiences with
  82. actual implementation they may have had.
  83.  
  84. To kick off discussion of this problem, John Peterson, who is researching this
  85. question at the University of Utah, was kind enough to spend some time on a
  86. response to me.  His reply follows (printed with his permission):
  87.  
  88. ------------------------------------------------------------------------------
  89.  
  90. RE ray tracing splines..  I've sent a paper on ray tracing splines via
  91. polygons to TOG, but since that's going to be stuck in the review process
  92. for a while, here's an overview:
  93.  
  94. Most of the recent published stuff on this have been approaches using
  95. numerical methods; which I would avoid like the plague.  I recently
  96. discovered that Whitted mentions surface subdivision very briefly in his
  97. classic paper (CACM '80) and also in Rubin & Whitted (SIGGRAPH '80).
  98. The technique they use was to subdivide the surface "on the fly", i.e.,
  99. an area of surface is split only when rays come near it.  Whitted
  100. doesn't go into any detail in these papers though, just a couple of
  101. paragraphs each.
  102.  
  103. However, Whitted's motivation for "subdivision on the fly" was lack of
  104. memory on his PDP-11 - nowadays I think you're better off just to do all
  105. the subdivision initially, then throw the surface away - much less
  106. bookkeeping.  The polygon/bounding volume database isn't that huge if you
  107. use adaptive surface subdivision (more on that in a moment).
  108.  
  109. In terms of references, I'd highly recommend the "Killer B's" - "An 
  110. Introduction to the Use of Splines in Computer Graphics" by Bartels,
  111. Beatty and Barsky.  It appeared as SIGGRAPH tutorial notes in '85 and
  112. '86, and I think a book version is coming out from Kaufmann(sp?) in
  113. September.  Another good reference is, "A Survey of Curve and Surface
  114. Methods in CAGD", by Bohm, Farin and Kahmann, in "Computer Aided Geometric
  115. Design", July 1984.  Both of these give excellent background on all the
  116. math you'll need for dealing with splines.  If you need to know about
  117. rationals, see Tiller's paper "Rational B-Splines for Curve and Surface
  118. Representations" in CG&A, September '83.
  119.  
  120. The subdivision algorithm I used is based on the Oslo Algorithm (Cohen,
  121. Lyche & Riesenfeld, Computer Graphics & Image Proc., Oct. 1980).  This
  122. is a little slower than some of the other subdivision algorithms, but
  123. the win is that you're not restricted to specific orders or knot
  124. vectors.  Since the subdivision time is generally small compared to the
  125. ray tracing time (like < 10%) I find it's worth the generality.  (By
  126. the way, the Killer B's description of the Oslo algorithm is much easier
  127. reading than the CG&IP article.  Sweeney's paper in the Feb. '86 CG&A
  128. also has a good description of it).  Other subdivision classics are Ed
  129. Catmull's PhD thesis (U. Utah, '75) and Lane, Carpenter, Whitted &
  130. Blinn's article in the Jan. '80 CACM.
  131.  
  132. A couple tricks are noteworthy.  First, if you're doing adaptive surface
  133. subdivision, you'll need a "flatness criteria" (to determine when to
  134. quit splitting the surface).  I've found a good approximation is to take
  135. the bounding box of the control mesh, and find the point in the middle
  136. of it.  Then project the size of a pixel onto this point, and use this
  137. distance as a flatness criteria.  
  138.  
  139. Other trick: Crack prevention.  If you split a surface into two parts,
  140. one part may get subdivided more than the other.  If this happens, along
  141. the seam between the two halves you need to force the polygon vertices in the
  142. side with more divisions to lie on the edge of the surface with fewer
  143. subdivisions.
  144.  
  145.  
  146. My reply to John follows:
  147.  
  148.     Thanks much for taking the time to tell me about splines and your
  149. findings.  You leave me in a quandary, though.  I'm interested in the
  150. numerical techniques for bicubics, but I also want to take your warnings to
  151. heart.
  152.  
  153.     I have to admit, I have a great fear of throwing away the nice
  154. compact spline description and blow it up into tons of polygons.  From your
  155. comments, you say that using adaptive techniques can help avoid this problem.
  156. You seem to divide to the pixel level as your criteria - hmmm, I'll have to
  157. think about that.  Avoiding cracks sounds like a headache.  Also, it seems to
  158. me that you'll have problems when you generate reflection rays, since for these
  159. rays the "flatness criteria" is not necessarily valid.  Have you ever noticed
  160. practical problems with this (one pathological example I can think of is a
  161. lens in front of a spline patch: the lens magnifies the pixel sized patches
  162. into much larger entities.  However, almost everything has pathological
  163. problems of some sort.  Have you run into any problems due to your method on a
  164. practical level)?
  165.  
  166.     I may try subdividing on the fly to avoid all this.  To this end, have
  167. you looked at Ron Pulleyblank's routine for calculating bicubic patch
  168. intersections (IEEE CG&A March 1987)?  What do you think of his "on the fly"
  169. subdivision algorithm?
  170.  
  171.     Articles: thanks for the references.  Have you seen the article by
  172. Levner, Tassinari, and Marini, "A Simple Method for Ray Tracing Bicubic
  173. Surfaces," in Computer Graphics 1987, T.L. Kunii editor, Springer-Verlag, Tokyo?
  174. Sounded intriguing - someone's hopefully going to get me a copy of it soon
  175. if you don't have it and would like a copy.  If you do have a copy, is it any
  176. good?
  177.  
  178. ----------------------------------------------------------------------------
  179.  
  180. Now, here's John's response:
  181.  
  182. RE: Numerical techniques.  I guess grim memories of round-off errors
  183. and consistently inconsistent results may bias my opinion, but there
  184. are some fundamental reasons for the problems with numerical methods.
  185. Finding roots of systems of two equations is inherently an unstable
  186. process (for a good description of this, see section 9.6 in "Numerical
  187. Recipes" by William Press, et. al.).  Another way to think about
  188. iterative approximations in two variables is the chaotic patterns
  189. you see Mandlebrot sets.  It's (very roughly) the same idea.  Chaos
  190. and ray tracing don't mix...
  191.  
  192. Your comments about the flatness criteria are true, though in practice
  193. I've only found one "practical" instance where it really poses a
  194. problem.  This is when a light source is very close to an object, and
  195. casts a shadow on a wall some distance away.  The shadow projection
  196. magnifies the surface's silhouette onto the wall, and in some cases
  197. you see some faceting in the shadow's edge.  The work-around is to
  198. have a per-surface "resolution factor" attribute.  The flatness
  199. criteria found by projecting the pixel is multiplied by this factor,
  200. so a surface with a "res factor" of 0.5 may generate up to twice as
  201. many polygons as it normally would (extra polygons are generated only
  202. where the surface is really curved, though).
  203.  
  204. In order to get a feel for just how much data subdivision generates, I
  205. tried the following experiment.  I took the code for balls.c (from
  206. the procedural database package you posted) and modified it to
  207. generate a rational quadratic Bezier surface for each sphere
  208. (as well as bounding volumes around each "group" of spheres).  I
  209. didn't do the formal benchmark case (too lazy), but just choose a view
  210. where all the spheres (level 2 == 91 of them) just filled the screen.
  211. The results look like this:
  212.  
  213.     Image Size  Triangles
  214.     (pixels)    generated
  215.     128x128         7800
  216.     512x512     30400
  217.  
  218. The original spline surface definition wasn't small, each sphere has
  219. 45 rational (homogeneous) control points + knot vectors.  My
  220. philosophy at the moment is that the algorithms for handling lots of
  221. trivial primatives win over those for handling a few complex ones.
  222. Right now the "lots of little primatives" camp has a lot of strong
  223. members (Octrees/Voxels, Kay/Kajiya/Caltech, Arvo & Co, etc).  If you
  224. just want to maximize speed, I think these are difficult to beat, but
  225. they do eat lots of memory.
  226.  
  227. I'd be very interested in seeing a software implementation of Pulleyblank's
  228. method.  The method seemed very clever, but it was very hardware oriented
  229. (lots of integer arithmetic, etc).  I guess the question is whether or not
  230. their subdivision algorithm is faster than just a database traversal.  
  231. Something like Kay/Kajiya or Arvo's traversal methods would probably scream
  232. if you could get them to run in strictly integer arithmetic (not to mention
  233. putting them in hardware...)
  234.  
  235. Cheers,
  236. jp
  237.  
  238. ----------------------------------------------------------------------------
  239.  
  240. Anywell, that's the discussion as far as it's gone.  We can continue it in one
  241. of two ways:  (1) everyone writes to everyone on the subject (this is quick,
  242. but can get confusing if there are a lot of answers), (2) send replies to me,
  243. which I'll then send to all.  I opt for (1) for now:  if things get confusing
  244. we can always shift to (2).
  245.  
  246. [Actually, we're shifting to (2) around now, though it seems worthwhile to
  247. pass on your comments to all, if you're set up to do it.  A summary of the
  248. comments will (eventually, probably) get put in Andrew's ray-tracing
  249. newsletter.]
  250.  
  251.  
  252. More responses so far:
  253.  
  254. >From Jeff Goldsmith:
  255.  
  256. Re: flatness criterion
  257.  
  258. The definition that JP gave seems to be based on pixel geometry.
  259. That doesn't seem right.  Why not subdivide until you reach 
  260. subpatches that have preset limits in the change in their 
  261. tangent vector (bounded curvature?)  Al Barr and Brian Von
  262. Herzen have done some formal studies of that in a paper given
  263. this year.  (It wasn't applied to ray tracing, but it doesn't
  264. matter.)  I used that technique for creating polygonal representations
  265. of superquadrics with fair to good success.  The geometric 
  266. criterion makes sure that not much happens to the surface
  267. within a patch, which is what you really want, anyway. 
  268.  
  269. I, too, by the way, believe in the gobs of polygons vs. one 
  270. compicated object tradeoff.  The two seem to be close in
  271. speed, but polygons saves big time in that you never need
  272. new code for your renderer.  I hate writing (debugging) 
  273. renderer code because it takes so long.  Modeling code
  274. is much faster.
  275.                 --Jeff
  276.  
  277.  
  278. >From Tim Kay:
  279.  
  280. Subject: ray tracing bicubic patches
  281.  
  282. The discussion about subdivision was interesting.  I just want to point
  283. out that a paper in this year's proceedings (Snyder and Barr) did just
  284. what the discussion suggested.  The teapot was modeled with patches,
  285. and John hacked them up into very small polygons.  He also talked about
  286. some of the problems that you run into.
  287.  
  288. Tim
  289.  
  290. ------------------
  291.  
  292. >From Brian Barsky:
  293.  
  294. What numerical techniques is John referring to?  He doesn't mean the 
  295. resolvent work, does he?
  296.  
  297. ----------------------------
  298.  
  299. Response from John Peterson:
  300.  
  301. I was using a modified version of Sweeney's method.  It was extended in
  302. two ways; first, a more effective means was used to generate the bounding
  303. volumes around the mesh, and it was able to handle surfaces with arbitrary
  304. orders and knot vectors.  I wrote up the results in a paper that appeared
  305. in a very obscure proceedings (ACM Rocky Mnt. Regional Conference,
  306. Santa Fe, NM, Nov. 1986)
  307.  
  308. ------------------------------------------------------
  309.  
  310.  
  311. ABNORMAL NORMALS:
  312.  
  313. >From Eric Haines:
  314.  
  315. My contribution for the week is an in-house memo I just wrote on transforming
  316. normals, which is easier that it sounds.  Some of you have undoubtedly dealt
  317. with this long ago, but hopefully I'll notify some poor soul that all is not
  318. simple with normal transforms.  Pat Hanrahan mentioned this problem in his talk
  319. at the SIGGRAPH '87 Intro to Ray Tracing course, but I didn't really understand
  320. why he was saying "don't use the modeling matrix to transform normals!"  Now
  321. I do, and I thought I'd explain it in a fairly informal way.  Any comments
  322. and corrections are appreciated!
  323.  
  324. The file's in troff format, run by:
  325.  
  326.     pic thisfile | troff -mm
  327.  
  328. (The document was written partly so that I could learn about troff and pic,
  329. so it's pretty primitive).
  330.  
  331.  
  332. All for now.  The file follows, indented by 4 spaces so that no "."'s would
  333. be in column one (which some e-mailers evidentally don't like).
  334.  
  335. ----------------------cut here---------------------
  336.     .tr ~
  337.     .ds HF 3 3 2 2 2 2 2
  338.     .nr Hi 0
  339.     .HM I A 1 a
  340.     .nr Ht 1
  341.     .nr Hb 6
  342.     .nr Hs 6
  343.     .nr Cl 7
  344.     .na
  345.     .fi
  346.     .ad l
  347.     \f(CS
  348.     .ce
  349.     Abnormal Normals
  350.     .ce
  351.     Eric Haines, 3D/Eye Inc.
  352.  
  353.     The problem:  given a polygon and its normal(s) and a modeling matrix, how
  354.     do we correctly transform the polygon from model to world space?  We assume
  355.     that the modeling matrix is affine (i.e. no perspective transformation is going
  356.     on).
  357.  
  358.     This question turns out to be fraught with peril.  The right answer is
  359.     to transform the vertices using the modeling matrix, and to transform the
  360.     normals using the transpose of the inverse (also known as the adjunct) of the
  361.     modeling matrix.  However, no one believes this on first glance.  Why do all
  362.     that extra work of taking the inverse and transposing it?  So, we'll present
  363.     the wrong answers (which are commonly used in the graphics community
  364.     nonetheless, sometimes with good reason), then talk about why the right answer
  365.     is right.
  366.  
  367.     Wrong answer #1:  Transform the normals using the modeling matrix.  What
  368.     this means is multiplying the normal [~x~y~z~0~] by the modeling matrix.  This
  369.     actually works just fine if the modeling matrix is formed from translation
  370.     matrices (which won't affect the normal transformation, since translations
  371.     multiply the 'w' component of the vector, which is 0 for normals) and rotation
  372.     matrices.  Scaling matrices are also legal, as long as the x, y, and z
  373.     components are the same (i.e. no "stretching" occurs).  Reflection matrices
  374.     (where the object is flipped through a mirror plane - more about these later)
  375.     are also legal, as long as there is no stretching.  Note that scaling will
  376.     change the overall length of the vector, but not the direction.
  377.  
  378.     So what's wrong?  Well, scaling matrices which stretch the object (i.e.
  379.     whose scaling factors are not all the same for x, y, and z) ruin this scheme.
  380.     Imagine you have a plane at a 45 degree tilt, formed by the equation
  381.     x~=~y (more formally, x~-~y~=~0).  Looking down upon the x-y plane from the z
  382.     axis, the plane would appear as a line x~=~y.  The plane normal is [~1~-1~0~]
  383.     (for simplicity don't worry about normalizing the vector), which would appear
  384.     to be a ray where x~=~-y, x~>~0.  Now, say we scale the plane by stretching
  385.     it along the x axis by 2, i.e. the matrix:
  386.  
  387.     [~2~0~0~0~]
  388.     .br
  389.     [~0~1~0~0~]
  390.     .br
  391.     [~0~0~1~0~]
  392.     .br
  393.     [~0~0~0~1~]
  394.  
  395.     This would form a plane in world space where x~=~2y.  Using the method of
  396.     multiplying the normal by this modeling matrix gives us a ray where x~=~-2y,
  397.     x~>~0.  The problem with this ray is that it is not perpendicular to our
  398.     plane.  In fact, the normal is now 2x~=~-y, x~>~0.  Therefore, using the
  399.     modeling matrix to transform normals is wrong for the
  400.     stretching case.
  401.  
  402.  
  403.     .DS
  404.     .PS 6.3
  405.  
  406.     # x-y grid
  407.     LX: arrow up up
  408.     "+y" at LX.end above
  409.     move to LX.end
  410.     move left 0.25
  411.     "before" "transform"
  412.     move to LX.start
  413.     LY: arrow right right
  414.     "+x" at LY.end ljust
  415.     move to LY.start
  416.     line left ; move to LY.start
  417.     line down ; move to LY.start
  418.  
  419.     # plane
  420.     M: line up right up right
  421.     "plane" at M.end + (-0.05,0.0) rjust
  422.     move to M.start
  423.     line down left
  424.     move to M.start
  425.  
  426.     N: arrow down right dashed
  427.     "normal" at N.end + (0.05,0.0) ljust
  428.     move to N.start
  429.  
  430.     ##############
  431.     move right 2.0
  432.     # x-y grid
  433.     LX: arrow up up
  434.     "+y" at LX.end above
  435.     move to LX.end
  436.     move left 0.25
  437.     "after" "transform"
  438.     move to LX.start
  439.     LY: arrow right right
  440.     "+x" at LY.end ljust
  441.     move to LY.start
  442.     line left ; move to LY.start
  443.     line down ; move to LY.start
  444.  
  445.     # plane
  446.     M: line up right right
  447.     "plane" at M.end + (-0.05,0.0) rjust
  448.     move to M.start
  449.     line down 0.25 left
  450.     move to M.start
  451.  
  452.     N: arrow down right right dashed
  453.     box invisible height 0.25 "bad" "normal" with .n at N.end
  454.     move to N.start
  455.  
  456.     N: arrow down right 0.25 dotted
  457.     box invisible height 0.25 "correct" "normal" with .n at N.end
  458.     move to N.start
  459.     .PE
  460.  
  461.  
  462.     .ce
  463.     Figure 1 (a) & (b) - Stretching Transformation
  464.     .DE
  465.     .na
  466.     .fi
  467.     .ad l
  468.  
  469.  
  470.     Wrong answer #2:  Transform the vertices, then calculate the normal.  This
  471.     is a limited response to the wrongness of method #1, solving the stretching
  472.     problem.  It's limited because this method assumes the normal is calculated
  473.     from the vertices.  This is not necessarily the case.  The normals could be
  474.     supplied by the user, given as a normal for the polygon, or on a normal per
  475.     vertex basis, or both.  However, even if the system only allowed normals which
  476.     were computed from the vertices, there would still be a direction problem.
  477.  
  478.     Say the method used to calculate the normal is to take the cross product of
  479.     the first two edges of the polygon (This is by far the most common method.
  480.     Most other methods based on the local geometry of the polygon will suffer from
  481.     the same problem, or else the problem in method #1).  Say the vertices are
  482.     [~1~0~0~], [~0~0~0~], and [~0~-1~0~].  The edge vectors (i.e. the vector formed
  483.     from subtracting one vertex on the edge from the other vertex forming that edge)
  484.     are [~1~0~0~] and [~0~1~0~], in other words the two edge vectors are parallel
  485.     to the +x and +y axes.  The normal is then [~0~0~1~], calculated from the cross
  486.     product of these vectors.
  487.  
  488.     If we transform the points by the reflection matrix:
  489.  
  490.     [~1~0~~0~0~]
  491.     .br
  492.     [~0~1~~0~0~]
  493.     .br
  494.     [~0~0~-1~0~]
  495.     .br
  496.     [~0~0~~0~1~]
  497.  
  498.     the result is the same: none of the edges actually moved.  However, when we
  499.     use a reflection matrix as a transform it is assumed that we want to reverse the
  500.     object's appearance.  With the above transform the expected result is that
  501.     the normal will be reversed, thereby reversing which side is thought of as
  502.     the front face.  Our method fails on these reflection transforms because it
  503.     does not reverse the normal:  no points changed location, so the normal will
  504.     be calculated as staying in the same direction.
  505.  
  506.     The right (?) answer:  What (usually) works is to transform the normals
  507.     with the transpose of the inverse of the modeling matrix.  Rather than trying
  508.     to give a full proof, I'll talk about the three types of matrices which are
  509.     relevant:  rotation, reflection, and scaling (stretching).  Translation was
  510.     already seen to have no effect on normals, so we can ignore it.  Other more
  511.     obscure affine transformations (e.g. shearing) are avoided in the discussion,
  512.     though the method should also hold for them.
  513.  
  514.     In the case of rotation matrices and reflection matrices, the transpose and
  515.     the inverse of these transforms are identical.  So, the transpose of the
  516.     inverse is simply the original modeling matrix in this case.  As we saw, using
  517.     the modeling matrix worked fine for these matrices in method #1.  The problems
  518.     occurred with stretching matrices.  For these, the inverse is not just a
  519.     transpose of the matrix, so the transpose of the inverse gives a different
  520.     kind of matrix.  This matrix solves our problems.  For example, with the bad
  521.     stretching case of method #1, the transpose of the inverse of the stretch
  522.     matrix is simply:
  523.  
  524.     [~0.5~0~0~0~]
  525.     .br
  526.     [~~0~~1~0~0~]
  527.     .br
  528.     [~~0~~0~1~0~]
  529.     .br
  530.     [~~0~~0~0~1~]
  531.  
  532.     (note that the transpose operation is not actually needed in this particular
  533.     case).  Multiplying our normal [~1~-1~0~] by this matrix yields [~0.5~-1~0~],
  534.     or the equation 2x~=~-y, x~>~0, which is the correct answer.
  535.  
  536.     The determinant:  One problem with taking the inverse is that sometimes
  537.     it isn't defined for various transforms.  For example, casting an object onto
  538.     a 2D x-y plane:
  539.  
  540.     [~1~0~0~0~]
  541.     .br
  542.     [~0~1~0~0~]
  543.     .br
  544.     [~0~0~0~0~]
  545.     .br
  546.     [~0~0~0~1~]
  547.  
  548.     does not have an inverse:  there's no way to know what the z component should
  549.     turn back into, given that the above transform matrix will always set the z
  550.     component to 0.  Essentially, information has been irretrievably destroyed
  551.     by this transform.  The determinant of the upper-left 3x3 matrix (the only
  552.     part of the matrix we really need to invert for the normal transform) is 0,
  553.     which means that this matrix is not invertable.
  554.  
  555.     An interesting property of the determinant is that it, coupled with method
  556.     #2, can make that method work.  If the determinant of the 3x3 is positive, we
  557.     have not shifted into the mirror world.  If it is negative, then we should
  558.     reverse the sign of the normal calculated as we have entered the mirror
  559.     universe).
  560.  
  561.     It would be nice to get a normal for polygons which have gone through this
  562.     transform.  All bets are off, but some interesting observations can be made.
  563.     The normal must be either [~0~0~1~] or its negative [~0~0~-1~] for this
  564.     transformation (or undefined, if all vertices are now on a single line).
  565.     Choosing which normal is a bit tricky.  One OK method is to check the normal
  566.     before transform against [~0~0~1~]: if the dot product of the two is negative,
  567.     then reverse the normal so that it will point towards the original direction.
  568.     However, if our points went through the z-reflection matrix we used earlier,
  569.     then went through the transform above, the normals were reversed, then the
  570.     object was cast onto the x-y plane.  In this case we would want to have the
  571.     reverse of the normal calculated from the edges.  However, this reversal has
  572.     been lost by our casting transform:  concatenating the reflection matrix with
  573.     the casting matrix yields the same casting matrix.  One tricky way of
  574.     preserving this is to allow 0 and -0 to be separate entities, with the sign of
  575.     zero telling us whether to reverse the normal or not.  This trick is rather
  576.     bizarre, though - it's probably easier to just do it the simple way and warn
  577.     whoever's using the system to avoid non-invertable transformations.
  578.  
  579. THE END:
  580.  
  581.     Well, that's all for now.  Do you have any comments? questions?
  582. interesting offerings for the group?  Either send your bit to everyone on the
  583. list, or send a copy on to me and I'll post it to all.  I realize this is
  584. quite a deluge of info for one message, but all of this has accumulated over a
  585. few months.  The traffic so far has been quite mild: don't worry about future
  586. flooding.
  587.  
  588.     All for now,
  589.  
  590.     Eric Haines
  591.  
  592. ----------------------------------------
  593.  
  594.  _ __                 ______                         _ __
  595. ' )  )                  /                           ' )  )
  596.  /--' __.  __  ,     --/ __  __.  _. o ____  _,      /  / _  , , , _
  597. /  \_(_/|_/ (_/_    (_/ / (_(_/|_(__<_/ / <_(_)_    /  (_</_(_(_/_/_)_
  598.              /                               /|
  599.             '                               |/
  600.  
  601. Ray Tracing News, e-mail edition, 1/15/88
  602.  
  603. concatenated by Eric Haines, hpfcla!hpfcrs!eye!erich@hplabs.HP.COM
  604.  
  605. Well, we've all been massively inactive as far as ray tracing news, what with
  606. SIGGRAPH and the holidays.  Now that the rush is over, I thought I'd pass on
  607. some additional comments on spline surfaces and how to ray-trace them, a
  608. polemic against octree subdivision, and end with a quick list of recommended
  609. books.  Finally, the updated mailing list (note that Andrew Glassner moved).
  610.  
  611. Speaking of whom, Andrew Glassner would like contributions to "The Ray Tracing
  612. News", hardcopy edition.  He hopes to publish another one soon, but says it may
  613. be the last if no one sends him any more material.  So, if you have an
  614. interesting technical memo or other short (less than 5 pages) piece you'd like
  615. to share with the rest of us, please write him (see the mailing list).
  616.  
  617.     All for now,
  618.  
  619.     Eric
  620.  
  621. ------------------------------------------------------------------------------
  622.  
  623.  
  624. From: hpfcla!hpda!uunet!mcvax!dutio!fwj (erik jansen)
  625. Subject: subdivision and CSG.
  626.  
  627. I went briefly through the discussion. I have been working on most items 
  628. the last five years. Some of the results are described in 'Solid modelling 
  629. with faceted primitives', my PhD thesis 'book'.  It is printed (108 pages) with
  630. a cover in colour. People who are interested in a free copy can mail me.
  631.  
  632. Here is the abstract::
  633.  
  634.  
  635.      Solid modelling with faceted primitives
  636.  
  637.      F.W. Jansen
  638.  
  639.  
  640.      Computer Aided Design and Computer Graphics techniques are valuable
  641.      tools in industrial design for the design and visualisation of
  642.      objects. For the internal representation of the geometry of objects,
  643.      several geometric modelling schemes are used. One approach, Con-
  644.      structive Solid Geometry (CSG), models objects as combinations of
  645.      primitive solids.  The subject of research in this project is a CSG
  646.      representation where the surfaces of the primitives are approximated
  647.      with flat surface elements (facets).  Techniques to improve the
  648.      efficiency of the display of models with a large number of these
  649.      surface elements have been developed.
  650.  
  651.           Two approaches have been taken.  The first approach is based on
  652.      the use of additional data structures to enhance the processing,
  653.      sorting and search of these surface elements.  Further, a method is
  654.      presented to store intermediate results of the logical computations
  655.      needed for the processing of CSG representations.  These methods are
  656.      applied to a CSG polygon modelling system.
  657.  
  658.           The second approach aims at the development of algorithms for
  659.      multi-processor systems and VLSI-based display systems.  The central
  660.      method is a CSG depth-buffer algorithm.  A tree traversal method is
  661.      introduced that combines several techniques to reduce the processing
  662.      and memory use.  The methods have been applied to a CSG halfspace
  663.      modelling system.
  664.  
  665.  
  666.           Keywords: computer graphics, geometric modelling, solid 
  667.      modelling, Constructive Solid Geometry (CSG), ray tracing algorithm,
  668.      depth-buffer algorithm, z-buffer algorithm, list-priority algorithm,
  669.      depth-priority algorithm, spatial subdivision, CSG classification, 
  670.      CSG coherence.
  671.  
  672. The following subjects are also included: adaptive subdivision, crack removal.
  673.  
  674. You can send this information to all. I will read the discussion more carefully
  675. and will comment on it later.
  676.  
  677. Erik Jansen
  678.  
  679. -------------------------------------------------------------------------------
  680.  
  681. From: Masataka Ohta <hpfcda!mohta%titcce.cc.titech.junet%utokyo-relay.csnet@RELAY.CS.NET>
  682. Subject: Bounded ray tracing
  683.  
  684. Dear Sir,
  685.  
  686. The discussions so far is very interesting one and I have
  687. several comments.
  688.  
  689. As I am charged for foreign mail (about $1 for 1K bytes, both
  690. incoming and out going), it costs considerablely to mail everyone
  691. on the list separately. So, I would like you to re-distribute
  692. my transpacific mail to everyone else.
  693.  
  694.                     Masataka Ohta
  695.  
  696. My comment on the flatness criteria with reflections follows:
  697. -----------------------------
  698.  
  699. Though I don't like subdividing patches into polygons for ray
  700. tracing (it's incoherent and, for example, CSG objects are
  701. difficult to render), good "flatness criteria" even with
  702. reflection, refraction or shadowing can be given using ray
  703. bound tracing.
  704.  
  705. The basic idea is simple. Ray bound is a combination of two
  706. bounds: a bound of ray origins and a bound of ray directions.
  707. A efficient bound can be formed by using a sphere for bounding
  708. ray origins and using a circle (on a unit sphere, i.e. using
  709. spherical geometry) for ray directions.
  710.  
  711. To begin with, bound a set of all rays which originates from
  712. each pixel. Flatness of a patch for the first generation ray
  713. should be computed against this ray bound, which is equivalent
  714. to measure flatness with perspective transformation, because
  715. rays are bounded by a pixel-sized cone.
  716.  
  717. As for the second generation rays, they can be bounded by a
  718. certain ray bound which can be calculated form the first
  719. generation ray bound. And those ray bounds should be used
  720. for the flatness check.
  721.  
  722. For those further interested in ray bound tracing, I will
  723. physically mail my paper titled "Bounded ray tracing for
  724. perfect and efficient anti-aliasing".
  725.  
  726. -------------------------------------------------------------------------------
  727.  
  728. From: Eric Haines
  729. Subject: Spline surface rendering, and what's wrong with octrees
  730.  
  731. Well, after all the discussion of spline surfaces, I finally went with turning
  732. the spline surface into patches, putting an octree around these, and then do
  733. Glassner/Kay/Fujimoto/etc octree ray-tracing (in reality I found Glassner's
  734. article the most useful, though I didn't use his hashing scheme due to (a)
  735. being pressed for time and (b) being pressed for memory space.  This seems to
  736. work fairly well, but I noticed some interesting problems with octrees that
  737. I thought I'd pass on.
  738.  
  739. ----------
  740.  
  741. [Note: this first problem is kinda boring if you've never implemented an octree
  742. subdivision scheme before.  Skip on to problem # 2, which I think is more
  743. important].
  744.  
  745. The first problem is: How do I cleverly chose octree bounds?  This problem was
  746. first mentioned to me by Mike Kaplan, which I did not think about much until I
  747. suddenly noticed that all available memory was getting gobbled by certain
  748. polygonalized splines.  The problem is that there are two parameters which are
  749. commonly used to end the further subdivision of an octree cube into its eight
  750. component "cubies".
  751.  
  752. One is a maximum number of primitives per octree cube.  To make the octree in
  753. the first place we have a bounding cube which contains the environment.  If
  754. the cube has more than a certain number of primitives in it, then octree
  755. subdivision takes place.  The octree cubies formed are then each treated in a
  756. like fashion, subdividing until all leaf cubies contain less than or equal to
  757. the number of primitives.  The second parameter is the maximum tree depth,
  758. which is the number of levels beyond which we will not subdivide cubes.  This
  759. parameter generally has precedence over the first parameter, i.e. if the
  760. maximum level has been reached but the maximum number of primitives is still
  761. exceeded, subdivision will nonetheless halt.
  762.  
  763. The trick is that you have to pay close attention to both parameters.
  764. Originally I set these parameters to some reasonable numbers: 6 primitives and
  765. 8 levels being my maximums.  What I found is that some objects would have
  766. very deep octrees, all the way down to level 8, even though their number of
  767. primitives was low.  For example, an object with 64 patches would still have
  768. some leaf nodes down at level 8 which had 7+ primitives in them.  I was
  769. pretty surprised by this problem.
  770.  
  771. My solution for spline surfaces was to keep the maximum number of primitives
  772. at 6 and use another parameter to determine the maximum level.  I use the
  773. formula:
  774.  
  775.     max level = round_up [ ln( primitives / K ) / ln( S ) ]
  776.  
  777. where K is the maximum number of primitives (i.e. 6) and S was a prediction of
  778. how much an octree subdivision would cut down the number of primitives in an
  779. octree.  For example, in an environment consisting of a set of randomly
  780. distributed points, one would expect that when the octree cube containing these
  781. points was subdivided into eight octree cubies, each octree cubie would have
  782. about 1/8th of the points inside it.  For a spline surface I reasoned that
  783. about four of the octree cubies might have some part of the surface in them,
  784. which would give an S=4 (Note that the largest, original octree must have at
  785. least four cubies filled by the surface.  However, this is not necessarily true
  786. for suceedingly smaller cubies).  Another factor which had to be taken into
  787. account was that there would also be some overlap: some primitives would appear
  788. in two or more cubies.  So, as a final reasonable guess I chose S=3.5 .  This
  789. seems to work fairly well in practice, though further testing would be very
  790. worthwhile.
  791.  
  792. Coming up with some optimal way to chose a maximum octree depth still seems to
  793. be an open question.  Further study on how various environments actually fill
  794. space would be worthwhile:  how many octree nodes really are filled on the
  795. average for each subdivision?  More pragmatically, how do we determine the
  796. best maximum depth for ray-tracing an environment?  The problem with not
  797. limiting the maximum level is primarily one of memory.  If the octree grows
  798. without reasonable bounds a simple scene could use all available memory.  Also,
  799. a large number of unnecessary octree nodes results in additional access time,
  800. either through having to search through the octree or through having extraneous
  801. objects in the hashing table.
  802.  
  803. A more intelligent approach might be to do adaptive subdivision: subdivide an
  804. octree cube as usual, then see how many fewer primitives there are in each
  805. cubie.  If some cube has more than some percentage of primitives in it, the
  806. subdivision could be deemed useless and so subdivision would end at this point.
  807. If anyone knows a master's candidate looking for a project, this whole question
  808. of when it is profitable to subdivide might make a worthwhile topic.  Judging
  809. from the interest in octrees by ray tracing researchers at last year's
  810. roundtable, I think this will become more and more important as time goes on.
  811.  
  812. -------------
  813.  
  814. The second problem with octrees:  I decided to go with octrees for spline
  815. surfaces only because these objects would have fairly localized and even
  816. distribution of primitives (i.e. quadrilateral patches).  I feel that octree
  817. efficiency techniques are probably horrible for ray tracing in general.
  818.  
  819. For example, imagine you have a football stadium made of, say, 5K primitives.
  820. Sitting on a goal line is a shiny polygonalized teapot of 5K quadrilaterals
  821. (note that the teapot is teapot sized compared to the stadium).  You fill the
  822. frame with the teapot for a ray trace, hoping to get some nice reflections of
  823. the stadium on its surface.
  824.  
  825. If you use an octree for this scene, you'll run into an interesting problem.
  826. The teapot is, say, a foot long.  The stadium is 200 yards long.  So, the
  827. teapot is going to be only 1/600th the size of the stadium.  Each octree
  828. subdivision creates 8 cubies which are each half the length of the parent
  829. cube.  You could well subdivide down to 9 levels (with that 9th level cubie
  830. having a length of 1/512th of the stadium length: about 14 inches) of octrees
  831. and still have the whole teapot inside one octree cube, still undivided.  If
  832. you stopped at this 9th level of subdivision, your ray trace would take
  833. forever.  Why?  Because whenever a ray would enter the octree cubie containing
  834. the teapot (which most of the rays from your eye would do, along with all those
  835. reflection and shadow rays), the cubie would contain a list of the 5K teapot
  836. polygons.  Each of these polygons would have to be tested against the ray,
  837. since there is no additional efficiency structure to help you out.  In this
  838. case the octree has been a total failure.
  839.  
  840. Now, you may be in a position where you know that your environments will be
  841. well behaved: you're ray tracing some specific object and the surrounding
  842. environment is limited in size.  However, the designer who is attempting to
  843. create a system which can respond to any user's modeling requests is still
  844. confronted by this problem.  Further subdivision beyond level nine down to
  845. level eighteen may solve the problem in this case.  But I can always come up
  846. with a worse pathological case.  Some realistic examples are an animation
  847. zooming in on a texture mapped earth into the Caltech campus:  when you're
  848. on the campus the sphere which represents the earth would create a huge
  849. octree node, and the campus would easily fall within one octree cubie.  Or
  850. a user simply wants to have a realistic sun, and places a spherical light
  851. source 93 million miles away from the scene being rendered.  Ridiculous?  Well,
  852. many times I find that I will place positional light sources quite some
  853. distance away from a scene, since I don't really care how far the light is,
  854. but just the direction the light is coming from.  If a primitive is associated
  855. with that light source, the octree suddenly gets huge.
  856.  
  857. Solutions?  Mine is simply to avoid the octree altogether and use Goldsmith's
  858. automatic bounding volume generation algorithm (IEEE CG&A, May 1987).  However,
  859. I hate to give up all that power of the octree so easily.  So, my question:
  860. has anyone found a good way around this problem?  One method might be to do
  861. octree subdivision down to a certain level, then consider all leaf cubies that
  862. have more than the specified number of primitives in their lists as "problem
  863. cubies".  For this list of primitives we perform Goldsmith's algorithm to get
  864. a nice bounding volume hierarchy.  This method reminds me of the SIGGRAPH 87
  865. paper by John Snyder and Alan Barr, "Ray Tracing Complex Models Containing
  866. Surface Tesselations".  Their paper uses SEADS on the tesselated primitives and
  867. hierarchy on these instanced SEADS boxes to get around memory constraints,
  868. while my idea is to use the octree for the total environment so that the
  869. quick cutoff feature of the octree can be used (i.e. if any primitive in an
  870. octree cubie is intersected, then ray trace testing is done, versus having to
  871. test the whole environment's hierarchy against the ray).  Using bounding
  872. volume hierarchy locally then gets rid of the pathological cases for the octree.
  873.  
  874. However, I tend to think the above just is not worthwhile.  It solves the
  875. pathological cases, but I think that automatic bounding volume hierarchy (let's
  876. call it ABVH) methods will be found to be comparable in speed to octrees in
  877. many cases.  I think I can justify that assertion, but first I would like to
  878. get your opinions about this problem.
  879.  
  880. -------------------------------------------------------------------------------
  881.  
  882. Top Ten Hit Parade of Computer Graphics Books
  883.     by Eric Haines
  884.  
  885. One of the most important resources I have as a computer graphics programmer
  886. is a good set of books, both for education and for reference.  However, there
  887. are a lot of wonderful books that I learn about years after I could have first
  888. used them.  Alternately, I will find that books I consider classics are unknown
  889. by others.  So, I would like to collect a list of recommended reading and
  890. reference from you all, to be published later in the year.  I would especially
  891. like a recommendation for good books on filtering and on analytic geometry.
  892. Right now I am reading _Digital Image Processing_ by Gonzalez and Wintz and have
  893. _A Programmer's Geometry_ on order, but am not sure these fit the bill.
  894. _An Introduction to Splines for use in Computer Graphics and Geometric
  895. Modeling_ by Bartels/Beatty/Barsky looks like a great resource on splines,
  896. but I have read only four chapters so far so am leaving it off the list for
  897. now.
  898.  
  899. Without further ado, here are my top ten book recommendations.  Most should be
  900. well known to you all, and so are listed mostly as a kernel of core books I
  901. consider useful.  I look forward to your additions!
  902.  
  903.     _The Elements of Programming Style, 2nd Edition_, Brian W. Kernighan,
  904.     P.J. Plauger, 168 pages, Bell Telephone Laboratories Inc, 1978.
  905.  
  906.     All programmers should read this book.  It is truly an "Elements of
  907.     Style" for programmers.  Examples of bad coding style are taken from
  908.     other textbooks, corrected, and discussed.  Wonderful and pithy.
  909.  
  910.     _Fundamentals of Interactive Computer Graphics_, James D. Foley, A. Van
  911.     Dam, 664 pages, Addison-Wesley Inc, 1982.
  912.  
  913.     A classic, covering just about everything once over lightly.
  914.  
  915.     _Principles of Interactive Computer Graphics, 2nd Edition_,  William M.
  916.     Newman, R.F. Sproull, 541 pages, McGraw-Hill Inc, 1979.
  917.  
  918.     The other classic.  It's older (e.g. ray-tracing did not exist at this
  919.     point), but gives another perspective on various algorithms.
  920.  
  921.     _Mathematical Elements for Computer Graphics_, David F. Rogers, J.A. Adams,
  922.     239 pages, McGraw-Hill Inc, 1976.
  923.  
  924.     An oldie but goodie, its major thrust is a thorough coverage of 2D and
  925.     3D transformations, along with some basics on spline curves and
  926.     surfaces.
  927.  
  928.     _Procedural Elements for Computer Graphics_, David F. Rogers, 433 pages,
  929.     McGraw-Hill Inc, 1985.
  930.  
  931.     For information on how to actually implement a wide variety of
  932.     graphics algorithms, from Bresenham's line drawer on up through
  933.     ray-tracing, this is the best book I know.  However, for complicated
  934.     algorithms I would recommend also reading the original papers.
  935.     
  936.     _Numerical Recipes_, William H. Press, B.P. Flannery, S.A. Teukolsky,
  937.     W.T. Vetterling, 818 pages, Cambridge University Press, 1986.
  938.  
  939.     Chock-full of information on numerical algorithms, including code
  940.     in FORTRAN and PASCAL (no "C", unfortunately).  The best part of
  941.     this book is that they give good advice on what methods are appropriate
  942.     for different types of problems.
  943.  
  944.     _A First Course in Numerical Analysis, 2nd Edition_, Anthony Ralston,
  945.     P. Rabinowitz, 556 pages, McGraw-Hill Inc, 1978.
  946.  
  947.     Tom Duff's recommendation says it best: "This book is SO GOOD [<-these
  948.     words should be printed in italics] that some colleges refuse to use
  949.     it as a text because of the difficulty of finding exam questions that
  950.     are not answered in the book".  It covers material in depth which
  951.     _Numerical Recipes_ glosses over.
  952.  
  953.     _C: A Reference Manual_, Samuel P. Harbison, G.L. Steele Jr., 352 pages,
  954.     Prentice-Hall Inc, 1984.
  955.  
  956.     A comprehensive and comprehensible manual on "C".
  957.  
  958.     _The Mythical Man-Month_, Frederick P. Brooks Jr, 195 pages, Addison-Wesley
  959.     Inc, 1982.
  960.  
  961.     A classic on the pitfalls of managing software projects, especially
  962.     large ones.  A great book for beginning to learn how to schedule
  963.     resources and make good predictions of when software really is going
  964.     to be finished.
  965.  
  966.     _Programming Pearls_, Jon Bentley, 195 pages, Bell Telephone Laboratories
  967.     Inc, 1986.
  968.  
  969.     Though directed more towards systems and business programmers, there
  970.     are a lot of clever coding techniques to be learnt from this book.
  971.     Also, it's just plain fun reading.
  972.  
  973. As an added bonus, here's one more that I could not resist:
  974.  
  975.     _Patterns in Nature_, Peter S. Stevens, 240 pages, Little, Brown and Co.
  976.     Inc, 1974.
  977.  
  978.     The thesis is that simple patterns recur again and again in nature and
  979.     for good reasons.  A quick read with wonderful photographs (my favorite
  980.     is the comparison of a turtle shell with a collection of bubbles
  981.     forming a similar shape).  Quite a few graphics researchers have used
  982.     this book for inspiration in simulating natural processes.
  983.  
  984. ---------------------------------
  985.  
  986. From Olin Lathrop:
  987.  
  988. Here goes another attempt to reach more people.  I will now spare you all
  989. a paragraph of griping about the e-mail system.
  990.  
  991. About the normal vector transform:
  992.  
  993. Eric, you are absolutely right.  I also ran into this when some of my squashed
  994. objects just didn't look right, about 4 years ago.  I would just like to offer
  995. a slightly different way of looking at the same thing.  I find I have difficulty
  996. with mathematical concepts unless I can attatch some sort of physical significance
  997. to them.  (I think of a 3x4 transformation matrix as three basis
  998. vectors and a displacement vector instead of an amorphous pile of 12 numbers.)
  999.  
  1000. My first attack at finding a transformed normal was to find two non-paralell
  1001. surface vectors at the point in question.  These could be transformed regularly
  1002. and the transformed normal would be their cross product.  This certainly 
  1003. works, but is computationally slow.  It seemed clear that there should exist
  1004. some 3x3 matrix that was the total transform the normal vector really went thru.
  1005. To simplify the thought experiment, what if the original normal vector was exactly
  1006. along the X axis?  Well, the unit surface vectors would be the Y and Z axis
  1007. vectors.  When these are sent thru the regular 3x3 transformation matrix, 
  1008. they become the Y and Z basis vectors of that matrix.  The final resulting
  1009. normal vector is therefore the cross product of the Y and Z basis vectors of the
  1010. regular matrix.  This is then what the X basis vector of the normal vector
  1011. transformation matrix should be.  In general, a basis vector in the normal
  1012. vector transformation matrix is the cross product of the other two basis
  1013. vectors of the regular transformation matrix.  I wasn't until about a year
  1014. later that I realized that this resulting matrix was the inverse transpose
  1015. of the regular one.  
  1016.  
  1017. This derivation results in exactly the same matrix that Eric was talking about,
  1018. but leaves me with more physical understanding of what it represents.
  1019.  
  1020. Now for a question:  It has always bothered me that this matrix trashes the
  1021. vector magnitude.  This usually implies re-unitizing the transformed normal
  1022. vector in practise.  Does anyone avoid this step?  I don't want to do any
  1023. more SQRTs than necessary.  You can assume that the original normal vector
  1024. was of unit length, but that the result also needs to be.
  1025.  
  1026.  
  1027. About octrees:
  1028.  
  1029. 1)  I don't use Andrew's hashing scheme either.  I transform the ray so that
  1030.   my octree always lives in the (0,0,0) to (1,1,1) cube.  To find the voxel
  1031.   containing any one point, I first convert the coordinates to 24 bit integers.
  1032.   The octree now sits in the 0 to 2**23 cube.  Picking off the most significant
  1033.   address bit for each coordinate yields a 3 bit number.  This is used to select
  1034.   one of 8 voxels at the top level.  Now pick off the next address bit down
  1035.   and chose the next level of subordinate voxel, etc, until you hit a leaf node.
  1036.   This process is LOGn, and is very quick in practise.  Finding a leaf voxel
  1037.   given an integer coordinate seems to consume about 2.5% of the time for most
  1038.   images.  I store direct pointers to subordinate voxels directly in the parent
  1039.   voxel data block.  In fact, this is the ONLY way I have of finding all but the
  1040.   top voxel.
  1041.  
  1042. 2)  Choosing subdivision criteria:  First, the biggest win is to subdivide on
  1043.   the fly.  Never subdivide anything until you find there is a demand for it.
  1044.   My current subdivision criteria in order of precidence (#1 overrides #2) are:
  1045.  
  1046.   1)  Do not subdivide if hit subdivision generation limit.  This is the same
  1047.     as what Eric talked about.  I think everyone does this.
  1048.  
  1049.   2)  Do not subdivide if voxel is empty.
  1050.  
  1051.   3)  Subdivide if voxel contains more than one object.
  1052.  
  1053.   4)  Do not subdivide if less than N rays passed thru this voxel, but did
  1054.     not hit anything.  Currently, N is set to 4.
  1055.  
  1056.   5)  Subdivide if M*K < N.  Where M is the number of rays that passed thru this
  1057.     voxel that DID hit something, and K is a parameter you chose.  Currently,
  1058.     K is set to 2, but I suspect it should be higher.  This step seeks to avoid
  1059.     subdividing a voxel that may be large, but has a good history of producing
  1060.     real intersections anyway.  Keep in mind that for every ray that did hit
  1061.     something, there are probably light source rays that did not hit anything.
  1062.     (The shader avoids launching light rays if the surface is facing away from
  1063.     the light source.)  This can distort the statistics, and make a voxel appear
  1064.     less "tight" than it really is, hence the need for larger values of K.
  1065.  
  1066.   6)  Subdivide.
  1067.  
  1068. Again, the most important point is lazy evaluation of the octree.  The above rules
  1069. are only applied when a ray passes thru a leaf node voxel.  Before any rays are
  1070. cast, my octree is exactly one leaf node containing all the objects.
  1071.  
  1072. 3) First solution to teapot in stadium:  This really cries out for nested objects.
  1073.   Jim Arvo, Dave Kirk, and I submitted a paper last year on "The Ray Tracing Kernel"
  1074.   which discussed applying object oriented programming to designing a ray tracer.
  1075.   Jim just told me he is going to reply about this in detail so I will make this
  1076.   real quick.  Basically, objects are only defined implicitly by the results of
  1077.   various standard operations they must be able to perform, like "intersect
  1078.   yourself with this ray".  The caller has no information HOW this is done.  An
  1079.   object can therefore be an "aggregate" object which really returns the result of
  1080.   intersecting the ray with all its subordinate objects.  this allows for easily
  1081.   and elegantly mixing storage techniques (octrees, linear space, 5D structures,
  1082.   etc.) in the same scene.  More on this from JIM.
  1083.  
  1084. 4) Second solution to teapot in stadium:  I didn't understand why an octree 
  1085.   wouldn't work well here anyway.  Suppose the teapot is completely enclosed
  1086.   in a level 8 voxel.  That would only "waste" 8x8=64 voxels in getting down
  1087.   to the space you would have chosen for just the teapot alone.  Reflection
  1088.   rays actually hitting the rest of the stadium would be very sparse, so go
  1089.   ahead and crank up the max subdivision limit.  Am I missing something?
  1090.  
  1091. -----------------------------------------------
  1092.  
  1093. (This is a reply to Olin Lathrop.  Summary: "well, maybe the octree is not so
  1094. bad after all...").
  1095.  
  1096. From: Eric Haines
  1097.  
  1098.  
  1099. Olin Lathrop writes:
  1100. > To simplify the thought experiment, what if the original normal vector was exactly
  1101. > along the X axis?  Well, the unit surface vectors would be the Y and Z axis
  1102. > vectors.  When these are sent thru the regular 3x3 transformation matrix, 
  1103. > they become the Y and Z basis vectors of that matrix.  The final resulting
  1104. > normal vector is therefore the cross product of the Y and Z basis vectors of the
  1105. > regular matrix.  This is then what the X basis vector of the normal vector
  1106. > transformation matrix should be.  In general, a basis vector in the normal
  1107. > vector transformation matrix is the cross product of the other two basis
  1108. > vectors of the regular transformation matrix.  It wasn't until about a year
  1109. > later that I realized that this resulting matrix was the inverse transpose
  1110. > of the regular one.  
  1111.  
  1112. The problem is the sign of the basis vector is unclear by this method.
  1113. I tried this approach, but it fails on mirror matrices.  Suppose your
  1114. transformation matrix is:
  1115. [ -1 0 0 0 ]
  1116. [  0 1 0 0 ]
  1117. [  0 0 1 0 ]
  1118. [  0 0 0 1 ]
  1119.  
  1120. This matrix definitely affects the surface normal in X, but your two vectors
  1121. in Y and Z are unaffected.  This problem never occurs in the "real" world
  1122. because such a matrix is equivalent to twisting an object through 4D space
  1123. and making it go "through the looking glass".  However, it happens in computer
  1124. graphics a lot:  e.g. I model half a car body, then mirror reflect to get the
  1125. other half.  If you have a two sided polygon laying in the YZ plane, with one
  1126. side red & the other blue, and apply the above transformation, no vertices
  1127. (and no tangent vectors) have any non-zero X components, and so will not change.
  1128. But the normal does reverse, and the sides switch colors.  My conclusion was
  1129. that you have to use the transpose of the inverse to avoid this problem, since
  1130. surface normals fail for this case. (p.s. did you get a copy of Glassner's
  1131. latest (2nd edition) memo on this problem?  He does a good job explaining the
  1132. math).
  1133.  
  1134. > About octrees:
  1135. >
  1136. > 1)  I don't use Andrew's hashing scheme either.  I transform the ray so that
  1137. >   my octree always lives in the (0,0,0) to (1,1,1) cube...
  1138.  
  1139. Actually, this is the exact approach I finally took, also.  I had rejected
  1140. the hashing scheme earlier, and forgotten why (and misremembered that it was
  1141. because of memory costs) - the correct reason for not hashing is that it's
  1142. faster to just zip through the octree by the above method; no hashing is
  1143. needed.  It's pretty durn fast to find the right voxel, I agree.
  1144.  
  1145. Have you experimented with trying to walk up and down the octree, that is, when
  1146. you are leaving an octree voxel you go up to the parent and see if the address
  1147. is inside the parent?  If not, you go to its parent and check the address, etc,
  1148. until you find that you can go back down.  Should be faster than the straight
  1149. downwards traversal when the octree is deep: the neighboring voxels of the
  1150. parent of the voxel you're presently in account for 3 of the 6 directions the
  1151. ray can go, after all.  You have 1/2 a chance of descending the octree if you
  1152. check the parent, 3/4ths if you go up two parents, etc.  (Where did I read of
  1153. this idea, anyway?  Fujimoto?  Kaplan?  Whatever the case, it's not original
  1154. with me).
  1155.  
  1156. Another idea that should be mentioned is one I first heard from Andrew
  1157. Glassner:  putting quadtree-like structures on the cube faces of the octree
  1158. cubes.  It's additional memory, but knowing which octree cube is the next would
  1159. be a faster process.  Hopefully Andrew will write this up sometime.
  1160.  
  1161. The subdivision criteria ideas are great - makes me want to go and try them
  1162. out!  When are you going to write it up and get it published somewhere? Lazy
  1163. subdivision sounds worthwhile: it definitely takes awhile for the octrees to
  1164. get set up under my present "do it all at the beginning" approach (not to
  1165. mention the memory costs).  That was something I loved about the Arvo/Kirk
  1166. paper - without it the 5D scheme would appear to be a serious memory hog.
  1167.  
  1168. > 4) Second solution to teapot in stadium:  I didn't understand why an octree 
  1169. >   wouldn't work well here anyway.  Suppose the teapot is completely enclosed
  1170. >   in a level 8 voxel.  That would only "waste" 8x8=64 voxels in getting down
  1171. >   to the space you would have chosen for just the teapot alone.  Reflection
  1172. >   rays actually hitting the rest of the stadium would be very sparse, so go
  1173. >   ahead and crank up the max subdivision limit.  Am I missing something?
  1174.  
  1175. There are two things which disturbed me about the use of the octree for this
  1176. problem.  One was that if the maximum subdivision level was reached prematurely
  1177. then the octree falls apart.  I mentioned that you could indeed subdivide down
  1178. another 9 levels and have an 18 level octree that would work.  However, the
  1179. problem with this is knowing when to stop - why not go on to 24 levels?  For
  1180. me it boils down to "when do I subdivide?".  I suspect that your additional
  1181. criteria might solve a lot of the pathological cases, which is why I want
  1182. to test them out.  Also note that there are built in maximum subdivision levels
  1183. in octree schemes which could be reached and still not be sufficient (though
  1184. admittedly your 24 levels of depth are probably enough.  Of course, I once
  1185. thought 16 bits was enough for a z-buffer - now I'm not so sure.  Say you have
  1186. a satellite which is 5 feet tall in an image, with the earth in the background.
  1187. We're now talking 23 levels of subdivision before you get within the realm
  1188. of subdividing the satellite.  With 24 levels of depth being your absolute
  1189. maximum you've hit the wall, with only one subdivision level helping you out
  1190. on the satellite itself).
  1191.  
  1192. Good point that as far as memory goes it's really just 8x8 more voxels "wasted".
  1193. One problem is: say I'm 8 feet in each direction from the teapot, with me and
  1194. the teapot in diagonally opposite corners of a cube which is then made into an
  1195. octree.  The only way to get through the 8 cubes in the containing box is to
  1196. travel through 4 of them (i.e. if I'm in Xhi, Yhi, Zhi and the teapot is in
  1197. Xlo, Ylo, Zlo, then I have to intersect my own box and then three other boxes
  1198. to move me through in each "lo" direction).  In this case there are only 3
  1199. levels of octree cubes I have to go through before getting to the 1 foot cube
  1200. voxel which contains the teapot.  The drawback of the octree is that I have to
  1201. then do 3x4=12 box intersections which must be done each ray and which are
  1202. useless.  Minor, but now think of reflection rays from the teapot which try to
  1203. hit the stadium: each could go through up to 8 levels x 4 voxels per level =
  1204. 32 voxels just to escape the stadium without hitting anything (not including
  1205. all the voxels needed to be traversed from the teapot to the one foot cube).
  1206. Seems like a lot of intersection and finding the next octree address and tree
  1207. traversal for hitting the background.  I suspect less bounding volumes would be
  1208. hit using hierarchy, and the tests would be simpler (many of them being just
  1209. a quick "is the ray origin inside this box?": if so, check inside the box).
  1210.  
  1211. I guess it just feels cleaner to have to intersect only bounding volumes
  1212. which are needed, which is the feel which automatic bounding volume hierarchy
  1213. has to it.  Boxes can be of any size, so that if someone adds a huge earth
  1214. behind a satellite all that is added is a box that contains both.  With
  1215. hierarchy you can do some simple tricks to cut down on the number of
  1216. bounding volumes intersected.  For example, by recording that the ray fired
  1217. at the last pixel hit such and so object, you can test this object first for
  1218. intersection.  This quickly gets you a maximum depth that you need not go
  1219. beyond: if a bounding volume is intersected beyond this distance you don't have
  1220. to worry about intersecting its contents.  This trick seems to gain you about
  1221. 90% of the speed-up of the octree (i.e. not having to intersect any more
  1222. voxels once an intersection is found), while also allowing you the speed up
  1223. of avoiding needless octree voxel intersections.  I call this the "ray
  1224. coherency" speedup - it can be used for all types of rays (and if you hit
  1225. when the ray is a shadow ray, you can immediately stop testing - this trick
  1226. will work for the octree, too!  Simply save a pointer to the object which
  1227. blocked a particular shadow ray for a particular light last pixel and try it
  1228. again for the next shadow ray).
  1229.  
  1230. I still have doubts about the octree.  However, with lazy evaluation I think
  1231. you get rid of one of my major concerns: subdividing too deep makes for massive
  1232. octrees which soak up tons of memory.  Have you had to deal with this problem,
  1233. i.e. has the octree ever gotten too big, and do you have some way to free up
  1234. memory (some "least recently used" kind of thing)?
  1235.  
  1236. An interesting comment that I read by John Peterson on USENET news some months
  1237. ago was:
  1238.  
  1239. >> [John Watson @ Ames:]
  1240. >> Anyway, I know there have been a few variations of the constant-time
  1241. >> algorithms around, and what I need to know is, what is the _best_, 
  1242. >> i.e. simplest, most effiecent, etc, ... version to implement.
  1243. >> 
  1244. >> Could some of you wonderful people comment on these techniques in general, 
  1245. >> and maybe give me some pointers on recent research, implementions, etc. 
  1246. >
  1247. > This is an interesting question.  Here at Utah, myself and Tom Malley
  1248. > implemented three different schemes in the same ray tracer; Whitted/Rubin,
  1249. > Kay/Kajiya, and an octree scheme (similar to the Glassner/Kaplan, camp, I
  1250. > think).  The result?  All three schemes were within 10-20% of each other
  1251. > speedwise.  Now, we haven't tested these times extensively; I'm sure you could
  1252. > find wider variances for pathological cases.  But on the few generic test
  1253. > cases we measured, there just wasn't much difference.  (If we get the time,
  1254. > we plan on benchmarking the three algorithms more closely).
  1255.  
  1256. I suspect that this is probably the case, with octree working best when the
  1257. scene depth (i.e. the number of objects which are intersected by each ray,
  1258. regardless of distance) is high, the "ray coherency" method outlined above for
  1259. hierarchy fails, and so cutting off early is a big benefit. Automatic hierarchy
  1260. probably wins when there are large irregularities in the density of the
  1261. number of objects in space.  (Of course, the SEADS method (equal sized voxels
  1262. and 3DDDA) is ridiculous for solving the "teapot in a stadium" kind of
  1263. problems, but it's probably great for machines with lots of memory ray tracing
  1264. scenes with a localized set of objects.
  1265.  
  1266. By the way, I found Whitted/Rubin vs. Kay/Kajiya to be about the same:  Kay had
  1267. less intersections, but the sorting killed any time gained.  I find the
  1268. coherency ray technique mostly does what Kay/Kajiya does: quickly gets you a
  1269. maximum intersection depth for cutoff.
  1270.  
  1271. Without the memory constraints limiting the effectiveness of the octree I can
  1272. believe it well could be the way of the future:  it is ideal for hardware
  1273. solution (so those extra voxel intersection and traversal tests don't bother me
  1274. if they're real fast), sort of like how the z-buffer is the present winner in
  1275. hidden surface algorithms because of its simplicity.
  1276.  
  1277. So, how's that for a turnabout on my polemical anti-octree position?
  1278. Nonetheless, I'm not planning to change my hierarchy code in the near future -
  1279. not until the subdivision and memory management problems are more fully
  1280. understood.
  1281.  
  1282. All for now,
  1283.  
  1284. Eric Haines
  1285.  
  1286.     
  1287. --------------------------------------------------
  1288.  
  1289.   SUBSPACES AND SIMULATED ANNEALING
  1290.  
  1291.   I  started  out  intending  to  write a very short reply to Eric Haines's
  1292.   "teapot in  a football stadium" example, but it turned out to  be  rather
  1293.   long.   At  any  rate,  most of what's described here (except for some of
  1294.   the very speculative stuff near  the bottom) is a result  of  joint  work
  1295.   with Dave Kirk, Olin Lathrop, and John Francis. 
  1296.  
  1297.   One  way  that  we've  dealt  with  situations  similar  to Eric's teapot
  1298.   example is to use a  combination  of  spatial  subdivision  and  bounding
  1299.   volume  techniques.   For  instance,  we commonly mix two or three of the
  1300.   following techniques into a  "meta" hierarchy for ray  tracing  a  single
  1301.   environment:
  1302.  
  1303.       1) Linear list 
  1304.       
  1305.       2) Bounding box hierarchy  
  1306.       
  1307.       3) Octrees  (including BSP trees) 
  1308.       
  1309.       4) Linear grid subdivision 
  1310.       
  1311.       5) Ray Classification      
  1312.       
  1313.   We  commonly  refer  to  these  as  "subspaces".   For us this means some
  1314.   (convex) volume of  space, a  collection  of  objects  in  it,  and  some
  1315.   technique  for  intersecting a ray with those objects.  This technique is
  1316.   part of an "aggregate  object", and all the objects it  manages  are  the
  1317.   "children".   Any  aggregate  object  can  be  the  child  of  any  other
  1318.   aggregate  object,  and   appears  simply  as  a  bounding   volume   and
  1319.   intersection  technique  to  its parent.  In other words, it behaves just
  1320.   like a primitive object. 
  1321.  
  1322.   Encapsulating a subspace as just another  "object"  is  very  convenient.
  1323.   This  is something which Dave and Olin and I agreed upon in order to make
  1324.   it possible to "mix  and  match"  our  favorite  acceleration  techniques
  1325.   within  the  same  ray  tracer for testing, benchmarking, and development
  1326.   purposes. 
  1327.  
  1328.   As an example of how we've used this  to  ray  trace  moderately  complex
  1329.   scenes  I'll  describe  the amusement park scene which we animated.  This
  1330.   consisted of a number of rides spread throughout a park, each  containing
  1331.   quite  a  bit  of  detail.   We  often  showed  closeups of objects which
  1332.   reflected the rest of the park (a somewhat scaled  down  version  of  the
  1333.   teapot  reflecting   the  stadium).   There  were somewhere around 10,000
  1334.   primitive objects  (not   including  fractal  mountains),  which  doesn't
  1335.   sound  like  much  anymore,  but  I   think  it still represents a fairly
  1336.   challenging scene to ray trace --  particularly for animating. 
  1337.  
  1338.   The organization of the scene suggested  three  very  natural  levels  of
  1339.   detail.  A typical example of this is
  1340.  
  1341.       I) Entire park ( a collection of rides, trees, and mountains )
  1342.   
  1343.           II) Triple decker Merry-go-round ( one of the rides )
  1344.   
  1345.               III) A character riding a horse ( a "detail" of a ride )
  1346.  
  1347.   Clearly  a single linear grid would not do well here because of the scale
  1348.   involved.  Very  significant  collections  of  primitives  would  end  up
  1349.   clumped  into  single  voxels.  Octress, on the other hand, can deal with
  1350.   this problem  but don't enjoy quite the  "voxel  walking"  speed  of  the
  1351.   linear grid.  This suggests a compromise. 
  1352.  
  1353.   What  we did initially was to place a coarse linear grid around the whole
  1354.   park, then  another  linear  grid  (or  octree)  around  each  ride,  and
  1355.   frequently  a  bounding box hierarchy around small clusters of primitives
  1356.   which would fall entirely with a voxel of even the second-level  (usually
  1357.   16x16x16) linear grid. 
  1358.  
  1359.   Later,  we  began to use ray classification at the top level because, for
  1360.   one thing, it did  some  optimizations  on  first-generation  rays.   The
  1361.   other   levels  of  the  hierarchy  were  kept in place for the most part
  1362.   (simplified a bit)  in order to run well on machines  with  <  16  MB  of
  1363.   physical  memory.   This  effectively  gave  the  RC (ray classification)
  1364.   aggregate object a "coarser" world to  deal  with,  and  drastically  cut
  1365.   down  the  size  of the candidate sets it built.  Of course, it also "put
  1366.   blinders" on it by not allowing it to distinguish between objects  inside
  1367.   these   "black  boxes"  it  was  handed.   It's  obviously  a  space-time
  1368.   trade-off.  Being able to nest the subspaces  provides  a  good  deal  of
  1369.   flexibility for making trade-offs like this. 
  1370.  
  1371.   A  small  but  sort  of interesting additional benefit which falls out of
  1372.   nesting  subspaces is that it's possible  to  take  better  advantage  of
  1373.   "sparse"  transformations.   Obviously the same trick of transforming the
  1374.   rays into a canonical object space  before doing  the  intersection  test
  1375.   (and  transform  the  normal  on  the  way  out) also works for aggregate
  1376.   objects.  Though this means doing possibly several transforms  of  a  ray
  1377.   before  it  even  gets  to a primitive object, quite often the transforms
  1378.   which are lower  in  the  hierarchy  are  very  simple  (e.g.  scale  and
  1379.   translate).   So,  there  are  cases  when  a  "dense"  (i.e.  expensive)
  1380.   transform gets you into  a  subspace  where  most  of  the  objects  have
  1381.   "sparse"  (i.e.  cheap)  transforms.  [I'll  gladly  describe how we take
  1382.   advantage of matrix sparsity structures if anybody  is  interested.]   If
  1383.   you  end   up  testing N objects before finding the closest intersection,
  1384.   this means that (occasionally)  you  can  do  the  job  with   one  dense
  1385.   transform  and  N  sparse  ones, instead of N dense transforms.   This is
  1386.   particularly appropriate when you build a  fairly  complex  object   from
  1387.   many  scaled  and  translated primitives, then rotate the whole mess into
  1388.   some strange final orientation.  Unfortunately, even in  this  case  it's
  1389.   not   necessarily   always  a  win.   Often  just  pre-concatenating  the
  1390.   transforms and tossing the autonomous objects (dense transforms and  all)
  1391.   into  the  parent  octree  (or  whatever) is the better thing to do.  The
  1392.   jury is still out on this one. 
  1393.  
  1394.   Currently, all of the "high level" decisions  about  which  subspaces  to
  1395.   place  where  are  all  made  manually  and  specified  in  the  modeling
  1396.   language.  This is much harder to do well  than  we  imagined  initially.
  1397.   The  tradeoffs  are  very  tricky  and  sometimes  counter-intuitive.   A
  1398.   general rule of thumb which seems to be of value is to put an  "adaptive"
  1399.   subspace  (e.g.  an  octree, RC) at the top level if the scene  has tight
  1400.   clusters of geometry, and  a  Linear  grid  if  the  geometry  is  fairly
  1401.   uniform.    Judicious  placement  of  bounding  box hierarchies within an
  1402.   adaptive hierarchy is a real art.  On the one hand,  you  don't  want  to
  1403.   hinder  the  effectiveness   of  the  adaptive subspace by creating large
  1404.   clumps of geometry that it  can't   partition.   On  the  other  hand,  a
  1405.   little  a  priori  knowledge  about  what's  important and where bounding
  1406.   boxes will do a good job can often make a big   difference  in  terms  of
  1407.   both time and space (the space part goes quintuple for RC). 
  1408.  
  1409.   Now,   the   obvious   question   to   ask  is  "How  can  this  be  done
  1410.   automatically?"  Something  akin  to  Goldsmith  and  Salmon's  automatic
  1411.   bounding  volume generation  algorithm may be appropriate.  Naturally, in
  1412.   this context, we're talking about a heterogeneous mixture  of  "volumes,"
  1413.   not  only  differing  in shape and surface area, but also in "cost," both
  1414.   in terms of space and time.  Think of each subspace as being  a  function
  1415.   which  allows you to intersect a ray with a set of objects with a certain
  1416.   expected (i.e. average) cost.  This  cost  is  very  dependent  upon  the
  1417.   spatial  arrangement  and  characteristics of the objects in the set, and
  1418.   each type of  subspace  provides  different   trade-offs.   Producing  an
  1419.   optimal  (or  at  least  good)  organization of  subspaces is then a very
  1420.   nasty combinatorial optimization problem.  
  1421.  
  1422.   An idea that I've been toying with for quite some  time  now  is  to  use
  1423.   "simulated  annealing"  to  find a near-optimal subspace hierarchy, where
  1424.   "optimality" can be phrased in terms of any  desired  objective  function
  1425.   (taking  into  account,  e.g., both space and time).  Simulated annealing
  1426.   is a technique for  probabilistically exploring the vast  solution  space
  1427.   (typically)   of   a  combinatorial  optimization  problem,  looking  for
  1428.   incremental improvements WITHOUT getting   stuck  too  soon  in  a  local
  1429.   minimum.   It's  very closely linked to some ideas in thermodynamics, and
  1430.   was  originally  motivated  by  nature's  ability  to  find  near-optimal
  1431.   solutions  to  mind-bogglingly  complex  optimization  problems  --  like
  1432.   getting all the water molecules in  a  lake  into  a  near-minimum-energy
  1433.   configuration  as  the temperature gradually reaches freezing.  It's been
  1434.   fairly successfull at "solving" NP-hard problems such  as  the  travaling
  1435.   salesman and chip placement (which are practically the same thing). 
  1436.  
  1437.   This  part  about  simulated  annealing  and  subspace hierarchies is all
  1438.   very  speculative, mind you.  It may not  be  practical  at  all.    It's
  1439.   easy  to  imagine  the  "annealing"  taking three  CPU-years to produce a
  1440.   data structure which takes an hour to  ray  trace  (if  it's  done  as  a
  1441.   preprocessing  step  --  not  lazily).   There  are  many details which I
  1442.   haven't discussed here -- largely because  I  haven't  figured  them  out
  1443.   yet.   For example, one needs to get a handle on the distribution of rays
  1444.   which will be intersected with the environment in order to  estimate  the
  1445.   efficiency  of the various subspaces.  Assuming a uniform distribution is
  1446.   probably a good first approximation,  but there's got to be a better  way
  1447.   --  perhaps  through  incremental improvements as the scene is ray traced
  1448.   and, in particular, between successive frames of an animation. 
  1449.  
  1450.   If this has any chance of working it's going to  require  an  interesting
  1451.   mix  of  science and "art".  The science is in efficiently estimating the
  1452.   effectiveness of a subspace (i.e. predicting the relevant costs) given  a
  1453.   collection  of  objects   and  a  probability  density  function  of rays
  1454.   (probably uniform).  The art is in  selecting  an   "annealing  schedule"
  1455.   which  will  let  the  various  combinations of hierarchies percolate and
  1456.   gradually  "freeze"  into  a  near-optimal  configuration.   Doing   this
  1457.   incrementally  for an animation is a further twist for which I've seen no
  1458.   analogies in the simulated annealing literature. 
  1459.  
  1460.   If you've never heard of simulated annealing  and  you're  interested  in
  1461.   reading  about  it,  there's  a  very  short  description  in  "Numerical
  1462.   Recipes."   The best  paper that I've found, though, is "Optimization  by
  1463.   Simulated  Annealing,"   by  S. Kirkpatrick, C. D. Gelatt, Jr., and M. P.
  1464.   Vecchi, in the May 13, 1983 issue  of Science. 
  1465.  
  1466.   Does this sound at all interesting to anybody?  Is anyone  else  thinking
  1467.   along  these or similar lines?  
  1468.   
  1469.                                                               -- Jim Arvo
  1470.